package jp.sourceforge.akjrcp.flvtools.dropsomething;

import java.io.File;

import jp.sourceforge.akjrcp.akj_betas.Akj_betasPlugin;
import jp.sourceforge.akjrcp.flvtools.basic.FFMpegPage;
import jp.sourceforge.akjrcp.util.FFMpegUtils;

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StackLayout;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Scale;

public class StretchAudioTab extends Composite{

	private Scale scaleSlider;
	private Composite controler;
	private StackLayout stack;
	private StretchAudioTab self;
	public StretchAudioTab(Composite parent, int style) {
		super(parent, style);
		self=this;
		stack = new StackLayout();
		this.setLayout(stack);
		
		controler = new Composite(this,SWT.NONE);
		controler.setLayout(new GridLayout(1,false));
		scaleSlider=new Scale(controler,SWT.NONE);
		scaleSlider.setMinimum(0);
		scaleSlider.setIncrement(10);
		scaleSlider.setSelection(60);
		scaleSlider.setMaximum(120);
		scaleSlider.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
		
		ValueDraw draw=new ValueDraw(controler,SWT.NONE);
		draw.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
		
		Button bt1=new Button(this,SWT.NONE);
		bt1.setText("click");
		bt1.addSelectionListener(new SelectionListener(){

			public void widgetSelected(SelectionEvent e) {
				stack.topControl=controler;
				String ffmpegPath=Akj_betasPlugin.getDefault().getPreferenceStore().getString(FFMpegPage.FFMPEG_PATH);
				if(!ffmpegPath.equals("") && new File(ffmpegPath).exists()){
					boolean available=FFMpegUtils.isAvisynthAvailable(new File(ffmpegPath));
					System.out.println(available);
				}
				
				self.layout();
			}

			public void widgetDefaultSelected(SelectionEvent e) {
				// TODO Auto-generated method stub
				
			}
			
		});
		stack.topControl=bt1;
	}
	
	public class ValueDraw extends Canvas implements PaintListener{
		public double values[]={0.25,0.33,0.5,0.57,0.66,0.8,1,1.25,1.5,1.75,2,3,4};
		public ValueDraw(Composite parent, int style) {
			super(parent, style);
			// TODO Auto-generated constructor stub
			this.addPaintListener(this);
		}
		public void paintControl(PaintEvent e){
	        int s=this.getClientArea().width/values.length;
	        
	        for (int i = 0; i < values.length; i++) {
				e.gc.drawString(""+values[i],i*s+16,20);
			}
	      }
		
	}


}
